package com.project.bookstore.book.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.project.bookstore.book.pojo.BookIndexVO;
import com.project.bookstore.book.pojo.BookMultiConditionVO;
import com.project.bookstore.book.entity.Book;
import com.project.bookstore.book.entity.BookIndex;
import com.project.bookstore.book.pojo.BookDetailVO;
import com.project.bookstore.book.pojo.BookNameByKeyWordVO;
import com.project.bookstore.cart.pojo.CartVO;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;
import java.util.Set;

@Mapper
public interface BookMapper extends BaseMapper<Book> {

    //首页书籍展示
    List<BookIndex> indexAllBook();

    int insertBook(BookDetailVO bookDetailVO);

    int deleteBookDetailById(Long id);

    //更新图书
    int updateBookDetailById(BookDetailVO bookDetailVO);

    //通过ID获取图书详情
    BookDetailVO getBookDetailById(Long id);

    //后台管理多条件查询
    List<BookMultiConditionVO> multiConditionForAdmin(BookMultiConditionVO vo);

    //批量启用
    int updateIsEnable1ByIds(Long[] ids);

    //批量禁用
    int updateIsEnable0ByIds(Long[] ids);

    //批量禁止销售
    int updateIsMarketable0ByIds(Long[] ids);

    //批量开启销售
    int updateIsMarketable1ByIds(Long[] ids);
    //通过书名查找书的详细信息
    BookDetailVO selectByBookName(String bookName);
    //通过关键词确定书籍
    List<BookNameByKeyWordVO> selectBookNameByKeyword(String keyword);

    //通过 书籍ID 数组获取图书购物车信息
    List<CartVO> listBookByIds(Long[] bookIds);

    //通过 ID 集合批量查询库存
    Integer[] selectCountById(List<Long> bookIds);

    //更新销量和库存
    int updateSaleCountPCSById(Long bookId, Integer count);

    //首页书籍展示数据
    List<BookIndexVO> selectForIndex();

    //根据类别ID获取相关书籍
    List<BookIndexVO> listBookByCategoryId(Long categoryId);
    //根据类别IDs获取相关书籍
    List<BookIndexVO> listBookByCategoryIds(Long[] classifyIds);
}
